package blockchain.block;


import java.util.ArrayList;

public class MerkleTreeBlockMy {
    public final MerkleTreeBlock myRoot;
    public ArrayList<Block> leafValues;
    public MerkleTreeBlockMy() {
        this.myRoot = new MerkleTreeBlock();
        this.leafValues = new ArrayList<>();
        myRoot.collectLeafValues(myRoot.root, leafValues);
    }
    public Block get(int i) {
        return leafValues.get(i);
    }
    public void add(Block block) {
        myRoot.addLeafNode(block);
        this.leafValues = new ArrayList<>();
        myRoot.collectLeafValues(myRoot.root, leafValues);
    }
    public void addBlock(String blockData) {
        Block block = new Block(blockData);
        this.add(block);
    }
    public int size() {
        return leafValues.size();
    }
}
